package com.juneng.utils.abnormal;

/**
 * @author JohnSoybean
 * @create 2020/3/19 15:54
 * @description 状态码及错误信息工具类
 */
public class CodeMsg {
    private Integer code;
    private String msg;

    private CodeMsg() {
    }
    private CodeMsg(int code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    // 登录模块 5003XX
    public static CodeMsg NO_CHECK = new CodeMsg(500301,"未完成选择");


    //通用的错误码
    public static CodeMsg SUCCESS = new CodeMsg(0, "success");
    public static CodeMsg SERVER_ERROR = new CodeMsg(500100, "服务端异常");
    public static CodeMsg BIND_ERROR = new CodeMsg(500101, "参数校验错误：%s");
    public static CodeMsg REQUEST_ILLEGAL = new CodeMsg(500102, "请求非法");
    public static CodeMsg ACCESS_LIMIT_REACHED= new CodeMsg(500104, "访问太频繁！");
    public static CodeMsg NULL_POINTER= new CodeMsg(500105, "空指针异常");
    public static CodeMsg MYSQL_CRUD_FAIL= new CodeMsg(500106, "数据库操作异常");
    public static CodeMsg PARAM_ABSENCE = new CodeMsg(500107, "缺少需要的参数");
    public static CodeMsg INFO_NOT_EXIST = new CodeMsg(500108, "该信息不存在");
    public static CodeMsg NO_HANDLER_FOUND =  new CodeMsg(500109, "404不存在");
    public static CodeMsg REDIS_CONNECT_ERR =  new CodeMsg(500110, "Redis连接失败");
    public static CodeMsg REDIS_OPERATE_ERR =  new CodeMsg(500110, "缓存操作失败");

    //登录模块 5002XX
    public static CodeMsg NO_TOKEN = new CodeMsg(500200, "请重新登录！");
    public static CodeMsg INVALID_TOKEN = new CodeMsg(500201, "已过期，请重新登录");
    public static CodeMsg ACCOUNT_BLOCKED = new CodeMsg(500202, "账号已被冻结");
    public static CodeMsg ACCOUNT_NOT_EXIST = new CodeMsg(500203, "账号不存在");
    public static CodeMsg WRONG_PASSWORD = new CodeMsg(500204, "密码错误！");
    public static CodeMsg INVALID_PASSWORD = new CodeMsg(500205, "无效的密码！");
    public static CodeMsg PWD_NOT_EXIST = new CodeMsg(500206, "账户未设置密码，请选择验证码登录方式！");
    public static CodeMsg EMPTY_ENTER = new CodeMsg(500207, "输入不能为空！");
    public static CodeMsg WRONG_CODE = new CodeMsg(500208, "验证码错误！");
    public static CodeMsg CERTIFICATION_FAIL = new CodeMsg(500208, "实名认证不通过！");
    public static CodeMsg WRONG_PHONE = new CodeMsg(500209, "手机号错误！");
    public static CodeMsg FIRST_LOGIN = new CodeMsg(500210, "首次登录");
    public static CodeMsg NOT_FIRST_LOGIN = new CodeMsg(500211, "非首次登录，只能用账号密码方式登录");
    public static CodeMsg ACCOUNT_VERIFIED = new CodeMsg(500212, "账号已实名认证过，无需重复认证");
    public static CodeMsg IDCARD_NOT_SAME = new CodeMsg(500213, "身份证照片信息与后台留存信息不一致");

    //商品模块 5003XX
    public static CodeMsg GOOD_NOT_EXIST = new CodeMsg(500300, "商品已下架");
    public static CodeMsg GOOD_NOT_MERCHANT = new CodeMsg(500301, "商品不属于当前配送区域");
    public static CodeMsg EMPTY_GOODS_ADDR = new CodeMsg(500303, "商品地址不能为空");
    public static CodeMsg NO_SUCH_GOODS = new CodeMsg(500304, "没有该商品");
    public static CodeMsg CHANGE_STOCK_FAIL = new CodeMsg(500305, "更改库存及销量失败");
    public static CodeMsg NO_GOODS_STAT = new CodeMsg(500306, "商品状态不存在");
    public static CodeMsg GOOD_STOCK_LACK = new CodeMsg(500307, "商品库存不足");
    public static CodeMsg NO_COMMODITY_CATEGORY = new CodeMsg(500308, "暂无商品分类信息");
    public static CodeMsg NO_BRAND = new CodeMsg(500309, "暂无品牌信息");
    public static CodeMsg NO_PRODUCT_INFORMATION = new CodeMsg(500310, "商品信息未填写完整");
    public static CodeMsg NO_PRODUCT_CHART = new CodeMsg(500311, "商品主图未填写");
    public static CodeMsg NO_PRODUCT_SPECIFICATIONS = new CodeMsg(500312, "暂无商品规格信息");
    public static CodeMsg NO_PRODUCT = new CodeMsg(500313, "暂无商品信息");
    public static CodeMsg UPDATE_PRODUCT = new CodeMsg(500314, "更改商品信息失败");
    public static CodeMsg UPDATE_PRODUCT_SKU = new CodeMsg(500315, "更改商品SKU信息失败");
    public static CodeMsg UPDATE_PRODUCT_MEMBER = new CodeMsg(500316, "修改商品会员价格失败");
    public static CodeMsg NO_PRODUCT_SKU = new CodeMsg(500317, "暂无商品sku信息");



    //订单及购物车模块 5004XX
    public static CodeMsg ORDER_NOT_EXIST = new CodeMsg(500400, "订单不存在");
    public static CodeMsg ORDER_NO_COMMENT = new CodeMsg(500401, "订单未评论");
    public static CodeMsg NO_DELIVERY = new CodeMsg(500402, "暂无收货地址");
    public static CodeMsg ORDER_INIT_ERR = new CodeMsg(500503, "创建订单失败");
    public static CodeMsg INTEGRAL_LACK = new CodeMsg(500504, "积分余额不足");
    public static CodeMsg MALL_ID_ERR = new CodeMsg(500505, "商城类别错误");
    public static CodeMsg ORDER_CANCEL_FAIL = new CodeMsg(500506, "订单取消失败");
    public static CodeMsg NO_PENDING_DELIVERY = new CodeMsg(500507, "无待发货订单");
    public static CodeMsg NO_ORDER_AMOUNT = new CodeMsg(500508, "暂无订单金额");
    public static CodeMsg NO_ORDER = new CodeMsg(500509, "未查到当前订单");


    //申请模块 5005XX
    public static CodeMsg SUBMIT_APPLY_FAIL = new CodeMsg(500500, "申请提交失败");

    //论坛模块 5006XX
    public static CodeMsg CREATE_LEAGUE_FAIL = new CodeMsg(500600, "创建联盟失败");
    public static CodeMsg JOIN_LEAGUE_FAIL = new CodeMsg(500601, "加入联盟失败");
    public static CodeMsg HAS_IN_LEAGUE = new CodeMsg(500602, "已在联盟中");
    public static CodeMsg EMPTY_SEARCH_ERR = new CodeMsg(500603, "清空搜索历史失败");
    public static CodeMsg POST_COMMENT_ERR = new CodeMsg(500604, "添加回答评论失败");
    public static CodeMsg ISSUE_ANSWERED = new CodeMsg(500605, "已回答过该问题");
    public static CodeMsg ADD_ISSUE_ERR = new CodeMsg(500606, "发布问题失败");
    public static CodeMsg NOT_IN_LEAGUE = new CodeMsg(500607, "您不在此联盟中");
    public static CodeMsg YOU_ARE_CAPTAIN = new CodeMsg(500608, "创建者仅能解散联盟，无法退出");
    public static CodeMsg YOU_ARE_NORMAL = new CodeMsg(500609, "您不是创建者，无法解散联盟");
    public static CodeMsg EXIT_LEAGUE_ERR = new CodeMsg(500610, "退出联盟失败");
    public static CodeMsg DISMISS_LEAGUE_ERR = new CodeMsg(500611, "解散联盟失败");
    public static CodeMsg KICK_MEMBER_FAIL = new CodeMsg(500612, "无法踢出该成员");
    public static CodeMsg KICK_AUTH_FAIL = new CodeMsg(500613, "无踢人权限");
    public static CodeMsg ISSUE_NOT_EXIST = new CodeMsg(500614, "帖子不存在");
    public static CodeMsg DELETE_ISSUE_AUTH_FAIL = new CodeMsg(500615, "无删帖权限");
    public static CodeMsg SHIELD_USER_FAIL = new CodeMsg(500616, "屏蔽用户失败");
    public static CodeMsg SHIELD_ISSUE_FAIL = new CodeMsg(500617, "屏蔽帖子失败");

    //福利模块 5007XX
    public static CodeMsg FREE_COUPON_EXPIRED = new CodeMsg(500700, "兑换券已过期");
    public static CodeMsg FREE_COUPON_USED = new CodeMsg(500701, "兑换券已使用");
    public static CodeMsg COUPON_USE_ERROR = new CodeMsg(500702, "优惠券使用失败");
    public static CodeMsg COUPON_DRAW_ERROR = new CodeMsg(500703, "优惠券领取失败");
    public static CodeMsg COUPON_DRAW_EXPIRED = new CodeMsg(500704, "不在领取时间内");
    public static CodeMsg COUPON_TYPE_ERROR = new CodeMsg(500705, "优惠券类型错误");
    public static CodeMsg VENUE_DATE_INVALID = new CodeMsg(500706, "当前日期不可预约");
    public static CodeMsg VENUE_APPOINT_FULL = new CodeMsg(500707, "当前日期人数已预约满");
    public static CodeMsg VENUE_DATE_APPOINTED = new CodeMsg(500708, "同一日期不能重复预约");
    public static CodeMsg VENUE_APPOINT_FAIL = new CodeMsg(500709, "预约失败");
    public static CodeMsg APPOINT_CHECK_FAIL = new CodeMsg(500710, "预约核销失败");
    public static CodeMsg VENUE_TIME_INVALID = new CodeMsg(500711, "已过当日可预约时间");
    public static CodeMsg SNAP_HAS_DRAWN = new CodeMsg(500712, "不可重复抢票");
    public static CodeMsg SNAP_DRAW_ERROR = new CodeMsg(500713, "抢票失败");
    public static CodeMsg SNAP_DRAW_EXPIRED = new CodeMsg(500714, "不在可抢票时间内");
    public static CodeMsg SNAP_DRAW_FULL = new CodeMsg(500715, "票已被抢完");
    public static CodeMsg COUPON_CHECK_FAIL = new CodeMsg(500716, "卡券核销失败");
    public static CodeMsg COUPON_EXPIRED = new CodeMsg(500717, "卡券已过期");
    public static CodeMsg VENUE_NOT_DATE = new CodeMsg(500718, "预约日期不在当天");
    public static CodeMsg NO_COUPON_INFORMATION = new CodeMsg(500719, "优惠券信息填写不完整");
    public static CodeMsg NO_COUPON_STORAGE = new CodeMsg(500720, "优惠券添加失败");
    public static CodeMsg NO_COUPON_NEWS = new CodeMsg(500721, "暂无优惠券信息");
    public static CodeMsg DELETE_COUPON = new CodeMsg(500722, "删除优惠券失败");
    public static CodeMsg NO_COUPON_USER = new CodeMsg(500723, "未选择用户或优惠券");


    //极光推送相关模块 5008XX
    public static CodeMsg DEVICE_SET_FAIL = new CodeMsg(500800, "设备推送信息设置失败");
    public static CodeMsg DEVICE_EMPTY_FAIL = new CodeMsg(500801, "设备推送信息清空失败");

    //文件上传模块 5009XX
    public static CodeMsg FILE_TOO_BIG = new CodeMsg(500900, "文件大小超过5M");
    public static CodeMsg FILE_NOT_EXIST = new CodeMsg(500901, "文件不存在");
    public static CodeMsg FILE_UPLOAD_FAIL = new CodeMsg(500902, "文件上传失败");
    public static CodeMsg FILE_TYPE_ERROR = new CodeMsg(500903, "文件类型错误");
    public static CodeMsg UPLOAD_IMAGE_FAIL = new CodeMsg(500904, "上传图片至OSS服务器失败");
    public static CodeMsg UPLOAD_VEDIO_FAIL = new CodeMsg(500905, "上传视频至OSS服务器失败");
    public static CodeMsg IMAGE_SIZE_OUT = new CodeMsg(500906, "图片大小超过10M");
    public static CodeMsg VEDIO_SIZE_OUT = new CodeMsg(500907, "视频大小超过50M");

    //ALIPAY模块 5010XX
    public static CodeMsg ALI_CERTIFY_INITIALIZE_ERR = new CodeMsg(501000, "支付宝实名认证初始化出错");
    public static CodeMsg ALI_CERTIFY_ACTION_ERR = new CodeMsg(501001, "支付宝实名认证执行出错");
    public static CodeMsg ALI_CERTIFY_QUERY_ERR = new CodeMsg(501002, "支付宝实名认证结果查询出错");
    public static CodeMsg ALI_CERTIFY_QUERY_FALSE = new CodeMsg(501003, "支付宝实名认证不通过，原因：%s");
    public static CodeMsg ACCOUNT_CERTIFIED = new CodeMsg(501004, "账号已经通过验证，请勿重复操作");

    //物业模块 5011XX
    public static CodeMsg ADD_OWNER_ERR = new CodeMsg(501100, "添加业主信息失败");

    //其他模块 5012xx
    public static CodeMsg FEEDBACK_SEND_ERR = new CodeMsg(501200, "意见反馈发送失败");
    public static CodeMsg CHAT_SEND_ERR = new CodeMsg(501201, "客服消息发送失败");

//    店铺 510000
    public static CodeMsg SHOP_INFORMATION = new CodeMsg(510001, "该用户不存在店铺");
    public static CodeMsg ON_SHOP_ORDER = new CodeMsg(510002, "该店铺暂无订单");
    public static CodeMsg ON_SHOP_DATA = new CodeMsg(510003, "店铺设置失败");
    public static CodeMsg ON_SHOP_USER = new CodeMsg(510004, "暂无店铺客户信息");

//    会员 510100
    public static CodeMsg NO_MEMBER = new CodeMsg(510101, "请输入会员信息");
    public static CodeMsg NO_UPDATE_MEMBER = new CodeMsg(510102, "修改会员信息失败");
    public static CodeMsg NO_INSERT_MEMBER = new CodeMsg(510103, "添加会员信息失败");
    public static CodeMsg NO_UPDATE_CUSTOMER_MEMBER = new CodeMsg(510104, "修改客户会员失败");


//    买家 510200
    public static CodeMsg ON_USER = new CodeMsg(510200, "用户信息不存在");
    public static CodeMsg ON_USER_RESTAURANT = new CodeMsg(510201, "无餐馆信息");

//    钱包 510300
    public static CodeMsg ON_SHOP_WALLET = new CodeMsg(510300, "暂无钱包信息");

//    银行卡 510400
    public static CodeMsg ON_BANK = new CodeMsg(510400, "银行卡信息填写不足");
    public static CodeMsg ON_STORAGE_BANK = new CodeMsg(510401, "银行卡信息存储失败");

//    消息 510500
    public static CodeMsg ON_NEWS = new CodeMsg(510501, "暂无消息");
    public static CodeMsg ON_SHOP_NEWS = new CodeMsg(510502, "该用户暂无消息");
    public static CodeMsg ON_NEWS_DETAILS = new CodeMsg(510503, "暂无消息详情");


    //通用错误码 600000
    public static CodeMsg ERR_CODE_MSG = new CodeMsg(600000, "%s");

    public Integer getCode() {
        return code;
    }

    public String getMsg() {
        return msg;
    }

    public CodeMsg fillArgs(String message) {
        //需要新建对象，否则将模板数据修改了
        CodeMsg codeMsg = new CodeMsg(this.code, this.msg);
        codeMsg.msg = String.format(codeMsg.msg, message);
        return codeMsg;
    }
}
